<template>
	<view>
        <!-- 公共组件-每个页面必须引入 -->
        <public-module></public-module>
		<nav-bar title="设置"></nav-bar>
		<view class="page_theme_bg">
			<view>
				<view class="nav_item" @click="onTokenJump('/pagesMy/my/editPassword')">
					<image src="../../static/icon/ic_password.png" mode="aspectFit"></image>
					<view class="info">
						<text>修改密码</text>
						<view class="arrow"></view>
					</view>
				</view>
				<view class="nav_item" @click="onTokenJump('/pagesMy/my/editPhone')">
					<image src="../../static/icon/ic_phone.png" mode="aspectFit"></image>
					<view class="info">
						<text>换绑手机</text>
						<view class="arrow"></view>
					</view>
				</view>
				<view class="nav_item" @click="onPageJump('/pages/user/protocol')">
					<image src="../../static/icon/ic_agreement.png" mode="aspectFit"></image>
					<view class="info">
						<text>用户协议</text>
						<view class="arrow"></view>
					</view>
				</view>
				<!-- #ifdef APP-PLUS -->
				<view class="nav_item" @click="onAPPUpdate">
					<image src="../../static/icon/ic_updatin.png" mode="aspectFit"></image>
					<view class="info">
						<text>检测更新</text>
						<view class="arrow">
							{{version}}
						</view>
					</view>
				</view>
				<!-- #endif -->
				<button class="sign_out" @click="onSignOut">退出登录</button>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	// #ifdef APP-PLUS
	import APPUpdate, {
		getCurrentNo
	} from '@/plugins/APPUpdate';
	// #endif
	export default {
		data() {
			return {
				version: "",
				noticeType:1000
			};
		},
		//第一次加载
		onLoad(e) {
			// #ifdef APP-PLUS
			getCurrentNo(res => {
				this.version = res.versionName;
			});
			// #endif
		},
		//页面显示
		onShow() {},
		//方法
		methods: {
			...mapMutations(["emptyUserInfo"]),
			onPageJump(url) {
				uni.navigateTo({
					url: url
				});
			},
			onTokenJump(url) {
				this.judgeLogin(() => {
					uni.navigateTo({
						url: url
					});
				});
			},
			// 退出
			onSignOut() {
				this.$http
					.get('api/mime/v1/sign_out')
					.then(res => {
						this.emptyUserInfo();
						uni.showToast({
							title: "退出成功",
							duration: 2000,
							success: () => {
								setTimeout(() => {
									uni.redirectTo({
										url: "/pages/user/login"
									});
								}, 2000)
							}
						});
					});
			},
			onAPPUpdate() {
				APPUpdate(true);
			}
		},
		//页面隐藏
		onHide() {},
		//页面卸载
		onUnload() {},
		//页面下来刷新
		onPullDownRefresh() {},
		//页面上拉触底
		onReachBottom() {},
		//用户点击分享
		onShareAppMessage(e) {
			return this.$base.share();
		}
	};
</script>
<style lang="scss" scoped>
	@import '@/style/mixin.scss';

	.nav_item {
		display: flex;
		align-items: center;
		padding-left: 30rpx;
		background-color: #FFF;

		image {
			width: 40rpx;
			height: 40rpx;
			margin-right: 40rpx;
			flex-shrink: 0;
		}

		.info {
			padding: 40rpx 30rpx 40rpx 0;
			border-bottom: 2rpx solid #f7f7f7;
			flex: 1;
			display: flex;
			align-items: center;
			justify-content: space-between;

			text {
				font-size: 28rpx;
				color: #333333;
			}
			.arrow {
				display: flex;
				align-items: center;
				font-size: 28rpx;
				color: #333333;

				&:after {
					content: "";
					@include bis('../../static/icon/icon_enter.png');
					width: 18rpx;
					height: 30rpx;
					margin-left: 30rpx;
				}
			}
		}
	}

	.sign_out {
		position: fixed;
		bottom: 30rpx;
		left: 30rpx;
		right: 30rpx;
		height: 88rpx;
		line-height: 88rpx;
		background-color: #ff5842;
		border-radius: 6rpx;
		font-size: 32rpx;
		color: #ffffff;
	}
</style>
